import 'package:flutter/material.dart';

class NavigatorService {
  // 定义单例
  static final NavigatorService _instance = NavigatorService._internal();
  NavigatorService._internal();
  factory NavigatorService() {
    return _instance;
  }

  final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

  Future<dynamic> pushTo(String routeName) {
    print(routeName);
    return navigatorKey.currentState.pushNamed(routeName, arguments: 'A');
  }

  void pop() {
    if (navigatorKey.currentState.canPop()) {
      navigatorKey.currentState.pop();
    }
  }
}
